package cheme.ProcessEditor.Figures;

import org.eclipse.draw2d.Border;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.swt.graphics.Color;

import cheme.ProcessEditor.ChemePresentation;

public class AbstractPresentableFig extends ChemeFigure
{
	protected static final int insetSpacing = 1;
	protected Insets insets = new Insets(insetSpacing);
	
	public AbstractPresentableFig()
	{
		super();
		initPresentation();
	}
	
	protected void initPresentation()
	{
	}
	
	public void setPresentation(Color Background, Color foreground, Border border)
	{
		setBackgroundColor(Background);
		setForegroundColor(foreground);
		setBorder(border);
	}
	
	@Override
	public Insets getInsets()
	{
		if(null == insets);
		{
			insets = new Insets(insetSpacing);
		}
		
		return insets;
	}
	
	@Override
	protected void paintFigure(Graphics graphics)
	{
		graphics.pushState();

			setTransperant(graphics, ChemePresentation.TableEditors.Tags.opacity);
			//fillGradient(graphics, ColorConstants.darkGray, ColorConstants.white);
			
			super.paintFigure(graphics);
		
		graphics.popState();
	}
	
	private void setTransperant(Graphics graphics, int alpha)
	{
		graphics.setAlpha(alpha);	
	}
	
//	private void fillGradient(Graphics graphics, Color top, Color bottom)
//	{
//		 graphics.setForegroundColor(top);
//		 graphics.setBackgroundColor(bottom);
//		 graphics.fillGradient(getBounds(), true);
//	}
}
